<template>
    <div>
        <div class="article-comment-title-warp">
            <p>看文章是喜欢，评论才是真爱：</p>
        </div>
        <el-input
        resize="none"
        :autosize="{minRows:6}"
        type="textarea"
        placeholder="请开始你的表演..."
        v-model="commentText"
        maxlength="1000"
        show-word-limit
        >
        </el-input>
        <div class="article-comment-submit-warp">
            <el-button @click="submit()" type="primary">评论</el-button>
        </div>
    </div>
</template>

<script>
export default {
    name:"articleCommentEditor",
    data(){
        return {
            commentText:""
        }
    },
    methods:{
        submit(){
            //提交之前记得检查下是否已经登录
            if(this.commentText.trim()===""||this.commentText.replace(/[\r\n]/g,"")===""){
                console.log("要评论得写点东西哦");
            }else{
                if(this.$store.state.isLogin){
                    this.$emit("articleCommentSubmit",this.commentText);
                }else{
                    this.$router.replace("/login");
                }
            }
        }
    }
}
</script>

<style>
.article-comment-submit-warp {
    display: flex;
    justify-content: flex-end;
    padding: 10px 10px;
}
.article-comment-title-warp {
    padding-bottom: 20px;
}
.article-comment-title-warp p {
    color: #ccc;
}
</style>